package dbutil;

import java.sql.Connection;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

public class Connect {
//	private Connection connection;
	public static final Connect SINGLETON = new Connect();

	private Connect() {
	}

	public Connection getConnection() {
		Connection connection = null;
		try {
			Context envCtx = (Context) new InitialContext()
					.lookup("java:comp/env");
			DataSource ds = (DataSource) envCtx.lookup("jdbc/TestDB");
			connection = ds.getConnection();
		} catch (Exception e) {
			System.out.println("Connection error: " + e.getMessage());
		}
		return connection;
	}

}
